# coding=utf-8
# -*- coding: UTF-8 -*-
#
# This file is part of the kernelstudio package.
#
# (c) 2014-2025 zlin <admin@kernelstudio.com>
#
# For the full copyright and license information, please view the LICENSE file
# that was distributed with this source code.
import os
import typing as t

from flask import send_from_directory

from ksai.context import ApplicationInitializer, Application


class WebResourcesInitializer(ApplicationInitializer):

    def initialize(self, app: Application) -> t.Any:
        @app.route('/assets/<path:filepath>')
        def static_files(filepath):
            return send_from_directory(app.config['STATIC_FOLDER'], os.path.join('assets', filepath))
